<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <grand-father></grand-father>
    </div>
    <script src="./node_modules/vue/dist/vue.js"></script>
    <script>
        // provide（提供） 和 inject（注入）
        let son = {
            inject: ['msg'],
            template: '<div>son -- {{msg}}</div>'
        }

        let father = {
            props: ['m'],
            template: '<div>Father<son :m="m"></son></div>',
            components: {
                son
            }
            
        }
        let grandFather = {
            // 提供者
            provide: {
                msg: "helloworld"
            },
            template: '<div>GrandFather<father :m="msg"></father></div>',
            components: {
                father
            },
            data() {
                return {
                    msg: "helloworld"
                }
            }
        }





        const app = new Vue({
            el: "#app",
            components: {
                grandFather
            }
        })
    </script>
</body>

</html>